package edu.sctu.practice.class02.lvchang.day20150929.exception;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * Created by Administrator on 2015/9/29.
 */
public class TryCatch {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        try {
            System.out.println("请输入除数a:");
            int a = input.nextInt();
            System.out.println("请输入被除数b:");
            int b = input.nextInt();
            System.out.println("两数字相除的结果a/b=" + a / b);
        } catch (InputMismatchException e) {
            System.out.println("请输入整数！！");
            e.printStackTrace();
        } catch (ArithmeticException e) {
            System.out.println("除数不能为零！！");
            e.printStackTrace();
        }

        System.out.println("程序结束了！！");
    }
}
